//
//  CoreData.h
//  MoneyIndividual
//
//  Created by Le Anh Tai on 1/6/14.
//  Copyright (c) 2014 Le Anh Tai. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface CoreData : NSObject

@property (nonatomic, strong) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, strong) NSManagedObjectModel *managedObjectModel;
@property (nonatomic, strong) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (nonatomic, strong) NSArray *accounts;
@property (nonatomic, strong) NSFetchedResultsController *fetchedNotificationsController;

+ (CoreData *)shared;

- (BOOL)saveContext;

- (NSManagedObject *)newEntity:(NSString *)entityName;
- (NSArray *)fetchEntity:(NSString *)entityName;
- (NSArray*)fetchEntity:(NSString*)entityName withPredicates:(NSArray *)predicates sortAttribute:(NSString*)attribute isAscending:(BOOL)isAscending;
- (NSArray*)fetchEntity:(NSString*)entityName withPredicate:(NSPredicate *)predicate sortAttribute:(NSString*)attribute isAscending:(BOOL)isAscending;
- (NSFetchedResultsController *)fetchedResultsControllerWithEntity:(NSString *)entityName
                                                      sortProperty:(NSString *)sortProperty
                                                       isAscending:(BOOL)isAscending
                                                           groupBy:(NSString *)groupByProperty
                                                         cacheName:(NSString *)cacheName;
- (NSFetchedResultsController *)fetchedResultsControllerWithEntity:(NSString *)entityName
                                                        predicates:(NSArray *)predicates
                                                      sortProperty:(NSString *)sortProperty
                                                       isAscending:(BOOL)isAscending
                                                           groupBy:(NSString *)groupByProperty
                                                         cacheName:(NSString *)cacheName;
- (NSFetchedResultsController *)fetchedResultsControllerWithEntity:(NSString *)entityName
                                                     andPredicates:(NSArray *)andPredicates
                                                      orPredicates:(NSArray *)orPredicates
                                                      sortProperties:(NSArray *)sortProperties
                                                       isAscending:(BOOL)isAscending
                                                           groupBy:(NSString *)groupByProperty
                                                         cacheName:(NSString *)cacheName;
- (BOOL)deleteObject:(NSManagedObject *)object;

@end
